package persistency.writer;

import java.util.Collection;
import java.util.Iterator;

public abstract class AssociationWriter extends Writer {
	
	/**
	 * Creates a new AssociationWriter Object
	 * @param filePath The file that will be used to store the data
	 * @param header The header that will be written in data file
	 */
	public AssociationWriter(String filePath, String header) {
		super(filePath, header);

	}

	/**
	 * Writes a collection of child data for a parent in an association text file
	 * @param parentKey The parent Primary key
	 * @param writables The collection of child data
	 */
	public void write(Object parentKey,Collection<? extends Writable> writables){
		Iterator<? extends Writable> writableIterator = writables.iterator();
		while (writableIterator.hasNext()) {
			write(parentKey+"\t"+ writableIterator.next().toDataString());
		}
	}
}
